﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;


using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;

namespace MINERP.DAL.Statistics
{
    public class ShopCrushAndArrearsDAL
    {
        public DataSet GetShopCrushAndArrears(DateTime startTime, DateTime endTime)
        {
            DataSet dsResult = new DataSet();
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("GetShopCrushMoneyRecords");
            db.AddInParameter(dbCommand, "startTime", DbType.DateTime, startTime);
            db.AddInParameter(dbCommand, "endTime", DbType.DateTime, endTime);

            try
            {
                dsResult = db.ExecuteDataSet(dbCommand);
            }
            catch (Exception)
            {
                return null;
            }

            return dsResult;
        }

        public DataSet GetSalesmanCrushAndArrears(DateTime startTime, DateTime endTime,string salesman)
        {
            DataSet dsResult = new DataSet();
            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetStoredProcCommand("GetSalesmanCrushMoneyRecords");
            db.AddInParameter(dbCommand, "@startTime", DbType.DateTime, startTime);
            db.AddInParameter(dbCommand, "@endTime", DbType.DateTime, endTime);
            db.AddInParameter(dbCommand, "@salesman", DbType.String, salesman);
            try
            {
                dsResult = db.ExecuteDataSet(dbCommand);
            }
            catch (Exception)
            {
                return null;
            }

            return dsResult;
        }
    }
}
